<template>
  <div class="app-container">
    <el-form :model="statistic" ref="default" size="small" :inline="true" label-width="68px">
      <el-form-item prop="year" style="width: 100px">
        <el-select v-model="statistic.year" @change="handleQuery">
          <el-option
            v-for="dict in dict.type.fs_hkjh_year"
            :key="dict.value"
            :label="dict.label"
            :value="parseInt(dict.value)"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item prop="month" style="width: 80px">
        <el-select v-model="statistic.month" @change="handleQuery">
          <el-option
            v-for="dict in dict.type.fs_hkjh_month"
            :key="dict.value"
            :label="dict.label"
            :value="parseInt(dict.value)"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item prop="zje" style="width: 150px">
        <span>
        总计：{{ statistic.zje }}元 &nbsp;({{ statistic.znum }}件)
        </span>
      </el-form-item>
      <el-form-item prop="dhje" style="width: 150px">
        <span style="color: #909399">
        待还：{{ statistic.dhje }}元 &nbsp;({{ statistic.dhnum }}件)
        </span>
      </el-form-item>
      <el-form-item prop="dshje" style="width: 150px">
        <span style="color: #1890ff">
        待审核：{{ statistic.dshje }}元 &nbsp;({{ statistic.dshnum }}件)
        </span>
      </el-form-item>
      <el-form-item prop="yhje" style="width: 150px">
        <span style="color: #13ce66">
        已还：{{ statistic.yhje }}元 &nbsp;({{ statistic.yhnum }}件)
        </span>
      </el-form-item>
      <el-form-item prop="yqje" style="width: 150px">
        <span style="color: #ff4949">
        逾期：{{ statistic.yqje }}元 &nbsp;({{ statistic.yqnum }}件)
        </span>
      </el-form-item>
    </el-form>

    <el-form :model="caseParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="88px">
      <el-form-item label="甲方识别码" prop="ah">
        <el-input
          v-model="caseParams.nbajbh"
          placeholder="请输入甲方识别码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="委托方批次">
        <el-select v-model="caseParams.zfid" placeholder="请选择委托方" clearable @change="getBatch">
          <el-option
            v-for="item in zfOptions"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          ></el-option>
        </el-select>
        <el-select v-model="caseParams.batchId" placeholder="请选择批次" clearable @change="handleQuery">
          <el-option
            v-for="item in pcOptions"
            :key="item.id"
            :label="item.batchName"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="诉讼主体">
        <el-select v-model="caseParams.ssztid" placeholder="请选择诉讼主体" clearable @change="handleQuery">
          <el-option
            v-for="item in ssztOptions"
            :key="item.id"
            :label="item.dwmc"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="被告" prop="ajmc">
        <el-input
          v-model="caseParams.ajmc"
          placeholder="请输入被告名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态" prop="zt">
        <el-select v-model="queryParams.zt" placeholder="请选择还款状态" clearable @change="handleQuery">
          <el-option
            v-for="dict in dict.type.fs_hkjh_zt"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['fs:schedule:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="scheduleList" @selection-change="handleSelectionChange">
      <el-table-column label="甲方识别码" align="center" prop="nbajbh">
        <template slot-scope="scope">
          <span>{{ scope.row.fsCase.nbajbh }}</span>
        </template>
      </el-table-column>
      <el-table-column label="资产包" align="center" prop="ajmc" width="180">
        <template slot-scope="scope">
          <span>{{ scope.row.fsCase.zfName }}</span>
          &nbsp;&nbsp;
          <span>{{ scope.row.fsCase.batchName }}</span>
          <br>
          <span>{{ scope.row.fsCase.ssztmc }}</span>
        </template>
      </el-table-column>
      <el-table-column label="被告" align="center" width="250">
        <template slot-scope="scope">
          <span>{{ scope.row.fsCase.bgDsr.xm }}</span>
          &nbsp;&nbsp;
          <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.fsCase.bgDsr.xb"/>
          &nbsp;&nbsp;
          <span>{{ scope.row.fsCase.bgDsr.sjhm }}</span>
          <br>
          <span>{{ scope.row.fsCase.bgDsr.zjhm }}</span>
          <br>
          <span>{{ scope.row.fsCase.bgDsr.dz }}</span>
        </template>
      </el-table-column>
      <el-table-column label="计划" align="center" prop="jhrq" width="180">
        <template slot-scope="scope">
          <span>{{ scope.row.jhje }}</span>
          <br>
          <span>{{ parseTime(scope.row.jhrq, '{y}-{m}-{d}') }}</span>
          <br>
          <span class="cellBtn">
            <el-button title="查看 还款计划"
                       size="mini"
                       type="text"
                       icon="el-icon-time"
                       @click="handleViewHkjh(scope.row)"
                       v-hasPermi="['fs:schedule:edit']"
            >
            </el-button>
          </span>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="zt">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.fs_hkjh_zt" :value="scope.row.zt"/>
        </template>
      </el-table-column>
      <el-table-column label="还款信息" align="center" prop="shrq" width="250">
        <template slot-scope="scope">
          <template v-for="(item,index) in scope.row.pays">
            <span>{{ item.shje }}元</span>&nbsp;
            <span>{{ parseTime(item.shrq, '{y}-{m}-{d}') }}</span>&nbsp;
            <dict-tag :options="dict.type.fs_hkjh_sh" :value="item.zt"/>&nbsp;
            <span v-if="item.zt==0" class="btn">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdatePay(item)"
                v-hasPermi="['fs:schedule:edit']"
              >
              </el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDeletePay(item)"
                v-hasPermi="['fs:schedule:edit']"
              >
              </el-button>
            </span>
            <br>
          </template>
        </template>
      </el-table-column>
      <el-table-column label="文件" align="center" prop="shrq" width="180">
        <template slot-scope="scope">
          <template v-for="(item,index) in scope.row.files">
            <el-link :key="index" type="primary" :href="item.oosUrl" target="_blank">{{ item.name }}</el-link>
            <br>
          </template>
        </template>
      </el-table-column>
      <el-table-column label="归属" align="center" width="120">
        <template slot-scope="scope">
          <span>律师： {{ scope.row.fsCase.owner }}</span>
          <br>
          <span>调解员： {{ scope.row.fsCase.tjy }}</span>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark"/>
      <el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width"
                       min-width="100px">
        <template slot-scope="scope">
          <el-button v-if="scope.row.zt==0"
                     size="mini"
                     type="text"
                     icon="el-icon-edit"
                     @click="handleUpdate(scope.row)"
                     v-hasPermi="['fs:schedule:edit']"
          >修改
          </el-button>
          <el-button v-if="scope.row.zt==0 || scope.row.zt==1"
                     size="mini"
                     type="text"
                     icon="el-icon-printer"
                     @click="handleHk(scope.row)"
                     v-hasPermi="['fs:schedule:edit']"
          >还款
          </el-button>
          <el-button v-if="scope.row.zt==3"
                     size="mini"
                     type="text"
                     icon="el-icon-refresh-left"
                     @click="handleDh(scope.row)"
                     v-hasPermi="['fs:schedule:edit']"
          >待还款
          </el-button>
          <el-button v-if="scope.row.zt==0"
                     size="mini"
                     type="text"
                     icon="el-icon-alarm-clock"
                     @click="handleYq(scope.row)"
                     v-hasPermi="['fs:schedule:edit']"
          >已逾期
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改还款计划对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="计划日期" prop="jhrq">
          <el-date-picker clearable
                          v-model="form.jhrq"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择计划日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="计划金额" prop="jhje">
          <el-input v-model="form.jhje" placeholder="请输入计划金额"/>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="hktitle" :visible.sync="hkopen" width="500px" append-to-body>
      <el-form ref="hkform" :model="hkform" :rules="hkrules" label-width="80px">
        <el-form-item label="此次还款" prop="hklx">
          <el-select v-model="hkform.hklx" placeholder="请选此次计划还款类型">
            <el-option
              v-for="dict in dict.type.fs_hkjh_hklx"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="实还金额" prop="shje">
          <el-input v-model="hkform.shje" placeholder="请输入实还金额"/>
        </el-form-item>
        <el-form-item label="实还日期" prop="shrq">
          <el-date-picker clearable
                          v-model="hkform.shrq"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择实还日期，如不填默认实时">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="缴费凭证" prop="shrq">
          <file-upload v-model="hkform.fileUrls" :mainId="hkform.scheduleId" :type="uploadType"
                       :fileList="hkform.fileList" :key="fileKey"
                       @removeFile="handleRemoveUploadFile">

          </file-upload>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="hkform.remark" type="textarea" placeholder="请输入内容"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitHk">确 定</el-button>
        <el-button @click="hkcancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 查看还款计划 -->
    <el-dialog :title="hkxqTitle" :visible.sync="hkxqOpen" width="800px" append-to-body>
      <el-form ref="hkform" :model="hkform" label-width="100px">
        <el-row>
          <el-col :span="8">
            <el-form-item label="还款金额" prop="hkje">
              {{ hkform.hkje }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="期数" prop="qs">
              {{ hkform.qs }}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="首次还款日" prop="schkr">
              {{ hkform.schkr }}
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-table class="hktable" :data="hkjhList">
        <el-table-column label="序号" align="center" prop="xh"/>
        <el-table-column label="计划日期" align="center" prop="jhrq">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.jhrq, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="计划金额" align="center" prop="jhje"/>
        <el-table-column label="备注" align="center" prop="remark" width="200px"/>
        <el-table-column label="状态" align="center" prop="zt">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.fs_hkjh_zt" :value="scope.row.zt"/>
          </template>
        </el-table-column>
        <el-table-column label="还款信息" align="center" prop="shrq" width="200px">
          <template slot-scope="scope">
            <template v-for="(item,index) in scope.row.pays">
              <span>{{ item.shje }}元</span>&nbsp;
              <span>{{ parseTime(item.shrq, '{y}-{m}-{d}') }}</span>&nbsp;
              <dict-tag :options="dict.type.fs_hkjh_sh" :value="item.zt"/>&nbsp;
              <br>
            </template>
          </template>
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button @click="hkxqcancel">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listSchedule,
  getSchedule,
  delSchedule,
  addSchedule,
  updateSchedule,
  getStatistic,
  eidtZt
} from "@/api/fs/schedule";
import {listPay, getPay, delPay, addPay, updatePay, delPayFile} from "@/api/fs/pay";
import {Div, Add, Sub, Mul, formatDate, formatNumber, toChineseNumber} from "@/api/fs/common";
import {getRepaymentByCaseId, listBatch, listSszt, listZf} from "@/api/fs/case";

export default {
  name: "Schedule",
  dicts: ['fs_hkjh_zt', 'fs_hkjh_sh', 'fs_hkjh_hklx', 'fs_hkjh_year', 'fs_hkjh_month', 'sys_user_sex'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      fileKey: 0,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 还款计划表格数据
      scheduleList: [],
      hkjhList: [],
      zfOptions: [],
      pcOptions: [],
      ssztOptions: [],
      // 弹出层标题
      title: "",
      hktitle: "",
      hkxqTitle: "",
      uploadType: 1,
      // 是否显示弹出层
      open: false,
      hkopen: false,
      hkxqOpen: false,
      statistic: {
        id: null,
        year: null,
        month: null,
        ssr: null,
        znum: 0,
        zje: 0,
        dhnum: 0,
        dhje: 0,
        dshnum: 0,
        dshje: 0,
        yhnum: 0,
        yhje: 0,
        yqnum: 0,
        yqje: 0
      },

      caseParams: {
        pageNum: 1,
        pageSize: 10,
        ah: null,
        yg: null,
        bg: null,
        ajlx: null,
        ajmc: null,
        fyid: null,
        sqbdje: null,
        sqlaay: null,
        zt: null,
        cjsj: null,
        gxsj: null,
        ownerId: null,
        ajzt: null,
        tjyId: null,
        sfid: null,
        sid: null,
        qxid: null,
        zfid: null,
        batchId: null,
        nbajbh: null,
        ssztid: null,
        lafs: null,
        ifPost: null,
        ifRepayment: null,
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        caseId: null,
        repaymentId: null,
        xh: null,
        jhrq: null,
        jhje: null,
        zt: null,
        shrq: null,
        shje: null,
        ssr: null,
        gxsj: null,
        shr: null,
        shsj: null,
        ny: null,
        params: null,
      },
      // 表单参数
      form: {},
      hkform: {},
      // 表单校验
      rules: {},
      hkrules: {
        shje: [
          {required: true, message: "实还金额不能为空", trigger: "change"}
        ],
        shrq: [
          {required: true, message: "实还日期不能为空", trigger: "change"}
        ],
        hklx: [
          {required: true, message: "还款类型不能为空", trigger: "change"}
        ],
      },
    };
  },
  activated() {
    const date = new Date();
    this.getList();
  },
  created() {
    let year = this.statistic.year;
    if (year || year == null || year == '') {
      const date = new Date();
      this.statistic.year = date.getFullYear();
      this.statistic.month = date.getMonth() + 1;
      this.getList();
    }
    this.getZf();
    this.getSszt();
  },
  mounted() {
  },
  methods: {
    getZf() {
      listZf().then(response => {
        this.zfOptions = response.data;
      });
    },
    getBatch() {
      this.caseParams.batchId = null;
      this.pcOptions = [];
      this.handleQuery();
      if (this.caseParams.zfid && this.caseParams.zfid > 0) {
        listBatch(this.caseParams.zfid).then(response => {
          this.pcOptions = response.data;
        });
      }
    },
    getSszt() {
      listSszt().then(response => {
        this.ssztOptions = response.data;
      });
    },
    /** 查询还款计划列表 */
    getList() {
      this.getStatistic();
      this.loading = true;
      let year = this.statistic.year;
      let month = this.statistic.month;
      const date = new Date(year, month - 1, 1);
      let beginTime = formatDate(date, 'yyyy-MM-dd');
      date.setMonth(date.getMonth() + 1, 0);
      let endTime = formatDate(date, 'yyyy-MM-dd');

      let params = {};
      params['beginTime'] = beginTime;
      params['endTime'] = endTime;
      if (this.caseParams.nbajbh) {
        params['nbajbh'] = this.caseParams.nbajbh;
      }
      if (this.caseParams.ajmc) {
        params['ajmc'] = this.caseParams.ajmc;
      }
      if (this.caseParams.zfid) {
        params['zfid'] = this.caseParams.zfid;
      }
      if (this.caseParams.batchId) {
        params['batchId'] = this.caseParams.batchId;
      }
      if (this.caseParams.ssztid) {
        params['ssztid'] = this.caseParams.ssztid;
      }
      this.queryParams.params = params;
      listSchedule(this.queryParams).then(response => {
        let list = response.rows;
        for (let i = 0; i < list.length; i++) {
          let item = list[i];
          let jhje = formatNumber(item.jhje.toFixed(2));
          let shje = formatNumber(item.shje.toFixed(2));
          item.jhje = jhje;
          item.shje = shje;
        }
        this.scheduleList = list;
        this.total = response.total;
        this.loading = false;
      });
    },
    getStatistic() {
      let year = this.statistic.year;
      let month = this.statistic.month;
      getStatistic(year, month).then(response => {
        let data = response.data;
        data.zje = formatNumber(data.zje.toFixed(2));
        data.dhje = formatNumber(data.dhje.toFixed(2));
        data.dshje = formatNumber(data.dshje.toFixed(2));
        data.yhje = formatNumber(data.yhje.toFixed(2));
        data.yqje = formatNumber(data.yqje.toFixed(2));
        this.statistic = data;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    hkcancel() {
      this.hkopen = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        caseId: null,
        repaymentId: null,
        xh: null,
        jhrq: null,
        jhje: null,
        zt: null,
        shrq: null,
        shje: null,
        ssr: null,
        gxsj: null,
        shr: null,
        shsj: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null
      };
      this.resetForm("form");
    },

    resetHk() {
      this.hkform = {
        id: null,
        scheduleId: null,
        repaymentId: null,
        shrq: null,
        shje: null,
        ssr: null,
        hklx: null,
        zt: null,
        shr: null,
        fileUrls: null,
        fileList: [],
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null
      };
      this.resetForm("hkform");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加还款计划";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getSchedule(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改还款计划";
      });
    },
    /** 修改按钮操作 */
    handleHk(row) {
      this.resetHk();
      const id = row.id || this.ids
      getSchedule(id).then(response => {
        this.hkform.scheduleId = response.data.id;
        this.hkform.repaymentId = response.data.repaymentId;
        this.hkform.ssr = response.data.ssr;
        this.hkopen = true;
        this.hktitle = "添加还款记录";
        this.fileKey++;
      });
    },
    handleUpdatePay(row) {
      let files = row.files;
      let fileUrls = "";
      let fileList = [];
      let temp = 1;
      if (files && files.length > 0) {
        for (let i = 0; i < files.length; i++) {
          fileUrls += files[i].oosUrl;
          if (i < (files.length - 1)) {
            fileUrls += ",";
          }
          let item = {name: files[i].name, url: files[i].oosUrl};
          item.uid = item.uid || new Date().getTime() + temp++;
          fileList[i] = item;
        }
      }
      this.resetHk();
      this.hkform = row;
      this.hkform.fileUrls = fileUrls;
      this.hkform.fileList = fileList;
      this.hkopen = true;
      this.hktitle = "修改还款记录";
      this.fileKey++;
    },
    handleDeletePay(row) {
      const id = row.id;
      this.$modal.confirm('是否确认删除此还款记录？').then(function () {
        return delPay(id);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    handleYq(row) {
      const id = row.id;
      this.$modal.confirm('确认要设置为 已逾期 吗？').then(function () {
        return eidtZt(id, 3);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("修改成功");
      }).catch(() => {
      });
    },
    handleDh(row) {
      const id = row.id;
      this.$modal.confirm('确认要设置为 待还款 吗？').then(function () {
        return eidtZt(id, 0);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("修改成功");
      }).catch(() => {
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            addPay(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            updatePay(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    submitHk() {
      this.$refs["hkform"].validate(valid => {
        if (valid) {
          console.log(this.hkform);
          if (this.hkform.id != null) {
            updatePay(this.hkform).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.hkopen = false;
              this.getList();
            });
          } else {
            addPay(this.hkform).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.hkopen = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除还款计划编号为"' + ids + '"的数据项？').then(function () {
        return delSchedule(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      let year = this.statistic.year;
      let month = this.statistic.month;
      const date = new Date(year, month - 1, 1);
      let beginTime = formatDate(date, 'yyyy-MM-dd');
      date.setMonth(date.getMonth() + 1, 0);
      let endTime = formatDate(date, 'yyyy-MM-dd');

      let params = {};
      params['beginTime'] = beginTime;
      params['endTime'] = endTime;
      if (this.caseParams.nbajbh) {
        params['nbajbh'] = this.caseParams.nbajbh;
      }
      if (this.caseParams.ajmc) {
        params['ajmc'] = this.caseParams.ajmc;
      }
      if (this.caseParams.zfid) {
        params['zfid'] = this.caseParams.zfid;
      }
      if (this.caseParams.batchId) {
        params['batchId'] = this.caseParams.batchId;
      }
      if (this.caseParams.ssztid) {
        params['ssztid'] = this.caseParams.ssztid;
      }
      this.queryParams.params = params;
      let fileName = "还款计划";
      fileName += "-" + year + "/" + month + ".xlsx";
      this.download('fs/schedule/export', {
        ...this.queryParams
      }, fileName)
    },
    handleRemoveUploadFile(file) {
      delPayFile(this.hkform.scheduleId, this.hkform.id, file.name);
    },
    hkxqcancel() {
      this.hkxqOpen = false;
      this.resetHk();
    },
    handleViewHkjh(row) {
      this.resetHk();
      getRepaymentByCaseId(row.caseId).then(response => {
        let data = response.data;
        this.hkform = data;
        let hkjhList = data.hkjhList;
        for (let i = 0; i < hkjhList.length; i++) {
          hkjhList[i].jhje = formatNumber(hkjhList[i].jhje.toFixed(2));
          hkjhList[i].shje = formatNumber(hkjhList[i].shje.toFixed(2));
        }
        this.hkjhList = hkjhList;
        this.hkxqOpen = true;
        this.hkxqTitle = "还款计划详情";
      });

    },
  }
};
</script>
<style>

.el-table__cell .cell div {
  display: inline;
}

.cell .el-link--inner {
  font-size: 12px;
}

.cellBtn button {
  font-size: 20px !important;
  padding: 0 !important;
}
</style>
